import { message } from 'ant-design-vue';

export const back=function(res, callback) {
  return res.status === 200 ? callback(res.data) : message.error('请求失败')
}

import FileSaver from 'file-saver'
import XLSX from 'xlsx'
export const downExcel=function(){
  let et=XLSX.utils.table_to_book(document.getElementById("feedbackList"));
  let out=XLSX.write(et,{
    bookSST:true,
    bookType:"xlsx",
    type:"array"
  });
  try{
    FileSaver.saveAs(
      new Blob([out],{
        type:"application/octet-stream"
      }),'导出文件.xlsx'
    );
  }catch(e){
    this.$message.info('导出失败'+e.toString());
  }
}

//获取当前 年月日时分秒
export const getCurrentime=function () {
  function checkTime(i) {
    if (i < 10) {
      i = "0" + i;
    }
    return i;
  }
  let today = new Date();
  let y = today.getFullYear();
  let m = today.getMonth();
  let d = today.getDate();
  let h = today.getHours();
  let i = today.getMinutes();
  let s = today.getSeconds(); // 在小于10的数字钱前加一个‘0’
  m = m + 1;
  d = checkTime(d);
  m = checkTime(m);
  i = checkTime(i);
  s = checkTime(s);
  let time = y + "-" + m + "-" + d + " " + h + ":" + i + ":" + s;
  return time;
};